package com.framework.base.taglib.ui.common; 

import java.util.List;

import javax.servlet.jsp.tagext.TagSupport;

import com.framework.base.util.MemCacheUtil;
import com.framework.base.util.StringUtil;
import com.framework.base.util.Struts2Utils;
import com.framework.main.sys.module.domain.ModuleOperationVO;

/** 
 * @Copyright @ 2012 
 * All right reserved 
 * @version 创建时间：Created on 2012-8-6 
 * @author 作者：Create by HYH
 * @Email: huyinhui2012@gmail.com
 * @description 用于控制权限的公共的类
 * 
 */
@SuppressWarnings("serial")
public class PowerTag extends TagSupport {
	
	/**
	 * 判断操作权限
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public boolean doJudgePower(String operation){
		boolean canOperation=false; //默认没有权限
		if(!StringUtil.isNullorEmpty(operation)){
			List<ModuleOperationVO> operationList= (List<ModuleOperationVO>) MemCacheUtil.readObject(Struts2Utils.getCurrentUser().getIdf()+"operation");
			if(!StringUtil.isNullorEmpty(operation)){
				for (ModuleOperationVO moduleOperationVO : operationList) {
					if(operation.equals(moduleOperationVO.getModuleidf()+"."+moduleOperationVO.getOperationIdf())){
						canOperation=true;
					}
				}
			}
		}else{
			canOperation=true;
		}
		return canOperation;
		
	}

}


